package com.jk1123.us.core.transfer;


import com.jk1123.us.common.transfer.RadixTransfer;
import com.jk1123.us.common.transfer.radix.LittleEndianRadix;

import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2021-09-03 00:03
 * @description
 */
@Warmup(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class RadixTransferBenchmark {

    private RadixTransfer transfer = new RadixTransfer(new LittleEndianRadix());

    @Param({"25", "50", "100", "200", "500", "1000"})
    private int length;
    @Setup
    public void prepare() {

    }

    private void doSomething() {
        //System.out.println("长度为:"+length);
        for (int i = 0; i < 10000; i++) {

            String s = transfer.num2string(i);
            long l = transfer.string2num("YX12Xu");
        }
    }
    @Benchmark
    @Threads(1)
    public void test1Thread() {
        doSomething();
    }
    @Benchmark
    @Threads(2)
    public void test2Thread() {
        doSomething();
    }
    @Benchmark
    @Threads(4)
    public void test4Thread() {
        doSomething();
    }
    @Benchmark
    @Threads(8)
    public void test8Thread() {
        doSomething();
    }
    @Benchmark
    @Threads(16)
    public void test16Thread() {
        doSomething();
    }



}